;; defun list-to-value (v-list)

(defun list-to-value (v-list)
  (cond ((null v-list) nil)
    ((eq (length v-list) 1)(car v-list))
    (t (cons '*OR* v-list))))

(defun parse-eng-morph (word)
  (cond 
    ((equal word "boys") '(("boys" +NIL) ("boy" +S)))
    ((equal word "sees") '(("sees" +NIL) ("see" +S)))
    (t (list (list word '+NIL)))))

(defvar *synlex*)

(setq *synlex*
      (make-hash-table :size 100 :test #'equal))

(defun make-entry (form)
  (if (stringp (first form))
      (cons `(root ,(first form)) (rest form))
    form))

(defun load-lexicon (file)
  (let (form old)
    (clrhash *synlex*)
    (with-open-file (in file :direction :input)
      (loop
       (setq form (read in nil in))
       (when (eq form in)
         (return))
       (format t "~%SYNLEX: ~s" form)
       (setq old (gethash (first form) *synlex*))
       (if old
           (setf (gethash (first form) *synlex*)
                 (append old (list (make-entry form))))
           (setf (gethash (first form) *synlex*)
                 (list (make-entry form))))))))

(load-lexicon "F:/class/NLPLab/workspace/nlp-lab/glr/glr-lexicon.lisp")

;; resutls
;; (((ROOT "man") (CAT N) (SEM *O-MAN-1))) 
;; (((ROOT "boy") (CAT N) (SEM *O-BOY-1))) 
;; (((ROOT "see") (CAT V) (VALENCY TRANS) (SEM *A-SEE-1))
;;  ((ROOT "see") (CAT V) (VALENCY INTRANS) (SEM *A-SEE-2))) 
;; (((ROOT "the") (CAT DET) (REFERENCE DEFINITE))) 
;; (((ROOT "a") (CAT DET) (REFERENCE INDEFINITE))) 
;; (((ROOT "with") (CAT P) (SEMROLE +INSTRUMENT)))

